package view.hall
{
	import core.Control;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import global.GameState;
	import global.Resource;
	
	import utils.ColorTool;
	
	import view.components.HintImgButton;
	import view.components.ImgButton;
	
	public class Hall extends Sprite
	{
		private var _control:Control = Control.getInstance();
		
		private var logo:DisplayObject;
		private var helpBut:HintImgButton;
		private var refreshBut:HintImgButton;
		public var enterBut:HintImgButton;
		public var fastBut:HintImgButton;
		
		private var taggleLeft:ImgButton;
		private var taggleRight:ImgButton;
	
		public function Hall()
		{
			initBg();
		
			initButs();
			initLogoImg();
			initTaggles();
		}
		
		private function initTaggles():void
		{
			taggleLeft = new ImgButton(10,155,0,onTaggle,70,20,"taggleBgLeft",null,"游戏场");
			addChild(taggleLeft);
			
			taggleRight = new ImgButton(80,155,0,onTaggle,70,20,"taggleBgRight",null,"比赛场");
			addChild(taggleRight);
		}
		
		private function onTaggle(event:MouseEvent):void
		{
			
		}
		
		private function initLogoImg():void
		{
			addChild(Resource.getImgXY(346,514,"face_logo"));
		}
		
		
		private function initButs():void
		{
			helpBut = new HintImgButton(8,490,0,onBut,Resource.getShape("bigBut"),-1,48,"text_panel_help",54,11);
			addChild(helpBut);
			
			refreshBut = new HintImgButton(199,490,1,onBut,Resource.getShape("bigBut2"),-1,48,"text_panel_refresh",25,11);
			addChild(refreshBut);
			
			var bg:DisplayObject = Resource.getShape("bigBut2");
			bg.scaleX = -1;
			bg.x = bg.width;
			enterBut = new HintImgButton(390,490,2,onBut,bg,-1,48,"text_panel_enter",78,11);
			addChild(enterBut);
			
			bg = Resource.getShape("bigBut");
			bg.scaleX = -1;
			bg.x = bg.width;
			fastBut = new HintImgButton(581,490,3,onBut,bg,-1,48,"text_panel_fast",28,11);
			addChild(fastBut);
			
			fastBut.startHint();
		}
		
		private function onBut(event:MouseEvent):void
		{
			switch (event.target.id)
			{
				case 0://help
					_control.helpPanelControl.open();
					break;
				
				case 2:
					_control.roomsListControl.enterRoom();
					break;
				case 1:
					_control.roomsListControl.refressList();
					break;
				case 3://快速进入
					_control.hallControl.onFastEnter();
					break;
			}
		}
		
		public function setLogo():void
		{
			logo = Resource.logo;
			logo.x = 10;
			logo.y = -6;
			addChild(logo);
		}
		
		private function initBg():void
		{
			/*with(this.graphics)
			{
				clear();
				beginFill(0);
				drawRect(0,0,GameState.GAME_WIDTH,GameState.GAME_HEIGHT);
				endFill();
			}*/
			ColorTool.drawHallbg(this.graphics,GameState.GAME_WIDTH,770);
		}
		

	}
}